MasterThe master bus of an AudioDevice: the final routing point that every Channel eventually connects into, and which connects to AudioContext.destination. Can also host its own effect chain and directly attached AudioClip instances via an internal AudioClipPlayer.
import { Master, Channel } from "@fluex/fluexgl-dsp";
const master = new Master(context);
const channel = new Channel(context);
channel.send(master);
Constructs a new Master channel, wiring input → effects → gainNode → analyserNode → context.destination, and creates its internal AudioClipPlayer.
new Master(context: AudioContext): Master;
context: AudioContext - The AudioContext used to create this master channel's internal audio nodes.id: stringA unique id, automatically generated when constructing a new master channel. Should NOT be changed.
channels: Channel[]All Channel instances currently attached to this master via attachChannel().
effects: Effector[]List of attached Effector instances, wired between input and gainNode.
input: GainNode | nullInput node of this master channel. Channels are connected here (directly, or through the effect chain) when attached.
gainNode: GainNode | nullGain node used to control the overall output volume of this master channel.
analyserNode: AnalyserNode | nullAnalyser node used for visualization / analysis of the master signal, placed right before context.destination.
context: AudioContext | nullThe AudioContext this master channel was constructed with.
audioClipPlayer: AudioClipPlayer | nullAudioClipPlayer owned by this master channel. Used to attach and play AudioClip instances directly into the master bus.
attachEffect(effect: Effector): voidAdds an Effector to this master channel, initializes it using this channel's AudioContext, and rebuilds the internal effect chain routing. Logs an error if the effect is already attached.
effect: Effector - The effect instance to attach.voiddetachEffect(effect: Effector): voidRemoves an attached Effector from this master channel and rebuilds the internal effect chain routing. Logs an error if the effect is not part of this master channel.
effect: Effector - The effect instance to detach.voidattachChannel(channel: Channel): voidRegisters a Channel as connected into this master channel's input. Logs an error if the channel is already attached. This is normally called for you via channel.send(master).
channel: Channel - The channel to attach.voiddetachChannel(channel: Channel): voidDisconnects a previously attached Channel from this master channel's input. Logs an error if the channel is not attached. This is normally called for you via channel.unsend(master).
channel: Channel - The channel to detach.voidhasAudioClipPlayer(): booleanReturns whether this master channel has a constructed AudioClipPlayer.
No arguments
boolean - true if audioClipPlayer is defined, otherwise false.attachAudioClip(audioClip: AudioClip): voidAttaches an AudioClip directly to this master channel via its internal AudioClipPlayer. Logs an error if this master channel has no audioClipPlayer.
audioClip: AudioClip - The audio clip to attach.voidThis class does not emit custom events.
This class does not define public getters or setters.
import { DspPipeline } from "@fluex/fluexgl-dsp";
(async function () {
const pipeline = new DspPipeline({
pathToWasm: "/data/fluexgl-dsp-wasm_bg.wasm",
pathToWorklet: "/data/fluexgl-dsp-processor.worklet"
});
await pipeline.initializeDpsPipeline();
const audioDevice = await pipeline.resolveDefaultAudioOutputDevice();
if (!audioDevice) return;
const master = audioDevice.getMasterChannel();
const channel = audioDevice.createChannel();
channel.send(master);
})();
import { AudioClip } from "@fluex/fluexgl-dsp";
const master = audioDevice.getMasterChannel();
const clip = new AudioClip(audioSourceData);
clip.send(master);
clip.play();